import React from 'react';
import ReactDOM from 'react-dom';

import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'

import { Provider } from 'mobx-react';

import { Tools, Toast, Bubble } from 'weaver-mobile';

import { FloatingTouch } from 'weaver-mobile-page';

import allStore from './stores';

import { asyncComponent } from 'react-async-component';

import './style';

const coms = {
    Home: asyncComponent({
        resolve: () => import("./components/Home")
    }),
    Center: asyncComponent({
        resolve: () => import("./components/center")  //流程中心
    }),
    Add: asyncComponent({
        resolve: () => import("./components/add")      //新建流程
    }),
    CreatorIdentity: asyncComponent({
        resolve: () => import("./components/add/CreatorIdentity")      //新建流程
    }),
    Agent: asyncComponent({
        resolve: () => import("./components/agent")     //流程代理
    }),
    Supervise: asyncComponent({
        resolve: () => import("./components/supervise")     //流程督办
    }),
    Monitor: asyncComponent({
        resolve: () => import("./components/monitor")     //流程监控
    }),
	CAAuth: asyncComponent({
       resolve: () => import("./components/caauth")     //流程二次验证，PC端扫描二维码打开的页面
    }),
    Attention:asyncComponent({
        resolve: () => import("./components/attention")     //流程关注
     }),
}

class Root extends React.Component {
    render() {
        return (
            <Provider {...allStore}>
                <Router>
                    <FloatingTouch onClick={() => this.onHomePageClick()}>
                    <Route name="home" path="/" render={() => {
                            return (
                                <coms.Home>
                                    <Route name="center" path="/center" component={coms.Center} />
                                    <Route name="add" path="/add" component={coms.Add} />
                                    <Route name="creatorIdentity" path="/creatorIdentity" component={coms.CreatorIdentity} />
                                    <Route name="agent" path="/agent" component ={coms.Agent} />
                                	<Route name="supervise" path="/supervise" component={coms.Supervise} />
                                	<Route name="monitor" path="/monitor" component={coms.Monitor} />
									<Route name="caauth" path="/caauth" component={coms.CAAuth}/>
                                    <Route name="attention" path="/attention" component={coms.Attention}/>   
                                </coms.Home>
                            )
                    }} />
                    </FloatingTouch>
                </Router>
            </Provider>
        )
    }
    onHomePageClick() {
        window.location.href = '/#/';
    }
}

Tools.getLocaleLabel("workflow", () => { // 多语言
    ReactDOM.render(<Root />, document.getElementById('root'));
});
